package model

import "time"

type Course struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	Name        string    `gorm:"size:100;not null;index:idx_name" json:"name"` // 添加索引：课程名称搜索
	Description string    `gorm:"type:text" json:"description"`
	CoachID     uint      `gorm:"index:idx_coach_id" json:"coachId"` // 添加索引：按教练查询课程
	MaxCapacity int       `gorm:"not null" json:"maxCapacity"`       // 最大容量
	Duration    int       `gorm:"not null" json:"duration"`          // 课程时长(分钟)
	StartTime   time.Time `gorm:"index:idx_start_time" json:"startTime"` // 添加索引：按时间范围查询和排序
	EndTime     time.Time `json:"endTime"`
	Status      int       `gorm:"default:1;index:idx_status" json:"status"` // 添加索引：筛选可预约课程
	CreatedAt   time.Time `gorm:"index:idx_created_at" json:"createdAt"`    // 添加索引：按创建时间排序
	UpdatedAt   time.Time `json:"updatedAt"`
}

type CourseCreateReq struct {
	Name        string `json:"name" binding:"required"`
	Description string `json:"description"`
	CoachID     uint   `json:"coachId" binding:"required"`
	MaxCapacity int    `json:"maxCapacity" binding:"required,min=1"`
	Duration    int    `json:"duration" binding:"required,min=1"`
	StartTime   string `json:"startTime" binding:"required"`
	EndTime     string `json:"endTime" binding:"required"`
}

type CourseUpdateReq struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	CoachID     *uint  `json:"coachId"`
	MaxCapacity *int   `json:"maxCapacity"`
	Duration    *int   `json:"duration"`
	StartTime   string `json:"startTime"`
	EndTime     string `json:"endTime"`
	Status      *int   `json:"status"`
}
